package com.lky.bean;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: Msg
 * @Author: Li_Kangyi
 * @Date: 2021/2/24 16:18
 * @Description: TODO 通用的返回的类
 */
public class Msg {
    private int code;//状态码！100成功，200失败
    private String msg;//提示信息

    //用户要返回的浏览器的数据
    private Map<String,Object> myExtend = new HashMap<String,Object>();

    //可以添加的附带数据：
    public Msg add(String key,Object value){
        this.getMyExtend().put(key,value);
        return this;
    }

    //成功
    public static Msg success(){
        Msg result = new Msg();
        result.setCode(100);
        result.setMsg("处理成功！");
        return result;
    }

    //失败
    public static Msg fail(){
        Msg result = new Msg();
        result.setCode(200);
        result.setMsg("处理失败！");
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getMyExtend() {
        return myExtend;
    }

    public void setMyExtend(Map<String, Object> myExtend) {
        this.myExtend = myExtend;
    }
}
